import { defineStore } from 'pinia'
import SelfStorage from './secure'

const USER_PERSIST_KEY = 'user'

export const useUserStore = defineStore('user', {
	state: () => ({
		userinfo: {}
	}),
	actions: {
		setUserinfo(info) {
			this.userinfo = info || {}
		},
		clear() {
			this.userinfo = {}
		}
	},
	persist:
		[
			{
				key: USER_PERSIST_KEY,
				storage: SelfStorage,
				paths: ['userinfo']
			}
		]

})

export default useUserStore


